package com.huangyi.mstemplateservice.controller;


import com.huangyi.commonredis.service.RedisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Validated
@RestController
@Slf4j
@RequestMapping("/test/redis")
public class TestRedisController {
    @Autowired
    private RedisService redisService;
    @RequestMapping("/addString")
    public String add() {
        redisService.setCacheObject("key", "value");
        return "success";
    }
    @RequestMapping("/getString")
    public String get() {
        String key = redisService.getCacheObject("key", String.class);
        log.info("key:{}", key);
        System.out.println(key);
        return "success";
    }

}
